package org.yoyo.classroom.service.impl;

import org.yoyo.classroom.mapper.RepairOrderMapper;
import org.yoyo.classroom.domain.po.RepairOrder;
import org.yoyo.classroom.service.RepairOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 维修工单业务逻辑层实现类
 */
@Service
public class RepairOrderServiceImpl implements RepairOrderService {

    @Autowired
    private RepairOrderMapper repairOrderMapper;

    /**
     * 根据ID查询维修工单
     * @param id 维修工单ID
     * @return 维修工单对象
     */
    @Override
    public RepairOrder getRepairOrderById(Long id) {
        return repairOrderMapper.selectById(id);
    }

    /**
     * 查询所有维修工单
     * @return 维修工单列表
     */
    @Override
    public List<RepairOrder> getAllRepairOrders() {
        return repairOrderMapper.selectAll();
    }

    /**
     * 插入维修工单
     * @param repairOrder 维修工单对象
     * @return 影响的行数
     */
    @Override
    public int addRepairOrder(RepairOrder repairOrder) {
        return repairOrderMapper.insert(repairOrder);
    }

    /**
     * 更新维修工单
     * @param repairOrder 维修工单对象
     * @return 影响的行数
     */
    @Override
    public int updateRepairOrder(RepairOrder repairOrder) {
        return repairOrderMapper.update(repairOrder);
    }

    /**
     * 删除维修工单（逻辑删除）
     * @param id 维修工单ID
     * @return 影响的行数
     */
    @Override
    public int deleteRepairOrder(Long id) {
        return repairOrderMapper.delete(id);
    }
}
